package com.amigo.online.provider.user.mapper;

import java.util.List;
import java.util.Map;

import com.amigo.online.provider.user.common.CommonCount;
import com.amigo.online.provider.user.model.entity.GroupNotice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import com.amigo.online.common.core.mybatis.MyMapper;
import com.amigo.online.common.param.result.GroupUserInfo;
import com.amigo.online.provider.user.model.entity.GroupMember;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface GroupMemberMapper extends MyMapper<GroupMember> {

    int updateRemind(GroupMember groupMember);

    int batchUpdateStatusExisted(List<GroupMember> members);

    List<GroupMember> selectExisted(Map<String, Object> params);

    List<GroupUserInfo> getMembersByGroupId(@Param("groupId") Long groupId, @Param("offset") Long offset, @Param("limit") Integer limit);

    int updateQuitByGroupIdAndUserId(GroupMember groupMember);

    Long getSecondMemberId(Long groupId);

    void changeGroupMemberHost(@Param("groupId") Long groupId, @Param("secondId") Long secondId, @Param("currentTime") Long currentTime);

    int getMembersCountByGroupId(Long groupId);

    List<CommonCount> getMembersCountByGroupIds(@Param("groupIds") List<Long> groupIds);

    @Update("update group_member_tbl set baned = 1, updated_time = #{updateTime} " +
            " where group_id = #{groupId} and user_id = #{userId}")
    int ban(@Param("groupId") Long groupId, @Param("userId") Long userId, @Param("updateTime") Long updateTime);

    int insertQuitNotice(GroupNotice groupNotice);

    int insertApplyGroupNotice(GroupNotice groupNotice);

    int updateApplyByGroupIdAndUserId(GroupMember member);

    GroupNotice selectIsApply(GroupNotice groupNotice);

    int updateMessageNotice(GroupNotice groupNotice);

}
